package high;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class join {
    public static void println(Object obj) {
        System.out.println(obj);
    }
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                println(Thread.currentThread().getName()+"开始运行了");

                try {
                    TimeUnit.SECONDS.sleep(5);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

                println(Thread.currentThread().getName()+"运行结束了");
            }
        },"线程1");
        thread.start();
        thread.join();          //调用线程先执行，父线程在子线程执行后执行
        println("主线程执行了...");
    }
}
